<!-- 门店补货单 -->
<template>
	<view>
		<u-sticky >
			<u-search placeholder="请输入订单编码" :clearabled="true" v-model="goodsNumber" border-color="#606266" @custom="getBHByGoodsNumber" ></u-search>
			<u-tabs name="cate_name" count="cate_count" :list="list" :is-scroll="false" :current="current" @change="changeType"></u-tabs>

		</u-sticky>
		
		 
		<u-card padding="16" v-for="(item,index) in dataList" :key="index" @click="clickCard(item)" >
			<view class="" slot="head">
				<view class="wrap">
					
					<u-row>
						<u-col span="9" text-align="left">
							<view class="weikaishi6">
								<span><u-icon name="order" size="26" labelSize="13px" labelColor="#000000" label=""></u-icon>{{item.orderOutNumber}}</span>
							</view>
						</u-col>
						<u-col span="3" text-align="left">
							<view class="weikaishi6">
								 <u-tag :text="item.orderType" type="warning" plain shape="circle"></u-tag>
							</view>
						</u-col>
						
					</u-row>
					<u-row>
						<u-col span="12" text-align="left">
							<view class="weikaishi6">
								<span style="color:dodgerblue;"><u-icon name="home" size="26" labelSize="13px" labelColor="#dodgerblue" label="要货门店"></u-icon>：{{item.getUnit}}</span>
							</view>
						</u-col>
						
					</u-row>
					<u-row>
						<u-col span="12" text-align="left">
							<view class="weikaishi6">
								<span style="color:dodgerblue;"><u-icon name="map" size="26" labelSize="13px" labelColor="#dodgerblue" label="发货仓库"></u-icon>：{{item.setWarehouse}}</span>
							</view>
						</u-col>
						
					</u-row>
					<u-row>
						<u-col span="12" text-align="left">
							<view class="weikaishi6">
								<span><u-icon name="man-add" size="26" labelSize="13px" labelColor="#000000" label="制单人"></u-icon>：{{item.createUserName}}</span>
							</view>
						</u-col>
						
					</u-row>
					<u-row>
						<u-col span="12" text-align="left">
							<view class="weikaishi6">
								<span><u-icon name="calendar" size="26" labelSize="13px" labelColor="#000000" label="制单时间"></u-icon>：{{item.createTime}}</span>
							</view>
						</u-col>
						
					</u-row>
					<u-row>
						<u-col span="12" text-align="left">
							<view class="weikaishi6">
								<span><u-icon name="car" size="26" labelSize="13px" labelColor="#000000" label="配送日期"></u-icon>：{{item.peisongTime}}</span>
							</view>
						</u-col>
						
					</u-row>
					<u-row>
						<u-col span="12" text-align="left">
							<view class="weikaishi6">
								<span style="color: crimson;"><u-icon name="red-packet" size="26" labelSize="13px" labelColor="#crimson" label="金额"></u-icon>：{{item.orderAmount}}</span>
							</view>
						</u-col>
						
					</u-row>
					<u-row>
						<u-col span="12" text-align="left">
							<view class="weikaishi6">
								<span><u-icon name="bookmark" size="26" labelSize="13px" labelColor="#000000" label="备注"></u-icon>：{{item.goodsNumber}}</span>
							</view>
						</u-col>
						
					</u-row>
					
					
					
					
				</view>
			</view>
			
		</u-card>
		<view>
			<u-calendar v-if="false"  v-model="show" mode="date" max-date="2070-01-01" @change="change" ></u-calendar>
		</view>
		<!-- <u-popup v-model="popupShow" mode="center" closeable width="660rpx" height="720rpx" border-radius="10">
			<view class="u-text-center u-m-t-20 weikaishi3"><u-icon name="order" size="30" labelSize="15px" labelColor="#000000" label="拣货明细"></u-icon></view>
			<u-card padding="16" v-for="(item,index) in dataList2" :key="index">
				<view class="" slot="head">
					<view class="wrap">
						<u-row>
							<u-col span="12">
								<view class="weikaishi3 lanse">
									<span>{{item.storageGoodsname}},{{item.goodsNo}}</span>
								</view>
							</u-col>
						</u-row>
					</view>
				</view>
				<view class="" slot="body">
					<view class="wrap">
						<u-row>
							<u-col span="5" text-align="center">
								<view class="weikaishi4 u-line-1 u-m-t-10">
									<span>批次</span>
								</view>
							</u-col>
							<u-col span="3" text-align="center">
								<view class="weikaishi4 u-line-1 u-m-t-10">
									<span>应拣</span>
								</view>
							</u-col>
							<u-col span="4" text-align="center">
								<view class="weikaishi4 u-line-1 u-m-t-10">
									<span>实拣</span>
								</view>
							</u-col>
						</u-row>
						<u-row v-for="(item1,index1) in item.list" :key="item1.id">
							<u-col span="5" text-align="center">
								<view class=" u-m-t-10 weikaishi4 huanghang">
									<span>{{item1.storageBatchnumber}}</span>
								</view>
							</u-col>
							<u-col span="3" text-align="center" v-if="item1.storageNumber == item1.realNum">
								<view class=" u-m-t-10 weikaishi4 yiwancheng">
									<span>{{item1.storageNumber}}</span>
								</view>
							</u-col>
							<u-col span="3" text-align="center" v-else>
								<view class=" u-m-t-10 weikaishi4">
									<span>{{item1.storageNumber}}</span>
								</view>
							</u-col>
							<u-col span="4" text-align="center" v-if="item1.storageNumber == item1.realNum">
								<view class=" u-m-t-10 weikaishi4 yiwancheng">
									<span>{{item1.realNum}}</span>
								</view>
							</u-col>
							<u-col span="4" text-align="center" v-else>
								<view class=" u-m-t-10 weikaishi4">
									<span>{{item1.realNum}}</span>
								</view>
							</u-col>
						</u-row>
					</view>
				</view>
			</u-card>
		</u-popup> -->
		<view>
			<u-toast ref="uToast" />
		</view>
		
	</view>
</template>
<script>

	export default {
		data() {
			return {
				setMentiontime:'',
				dataList: [],
				dataList2: [],
				show:false,
				popupShow:false,
				areanumberlist:[],
				goodsNumber:'',
				pageNo:1,
				hasMore: true,
				list: [{
						cate_name: '待提交'
					}, {
						cate_name: '待审核'
					}, {
						cate_name: '待付款'
					}],
				current: 0,
				orderState:'待提交'

			}
		},
		onLoad(open) {
			//#ifdef H5 || APP-PLUS
			this.flex = 'u-flex'
			//#endif
			this.refresh()
		},
		filters:{
			formatDate(value) {
			      if (!value) return ''; // 如果没有值，返回空字符串
			      const date = new Date(value); // 将日期字符串转换为 Date 对象
			      const year = date.getFullYear(); // 获取年份
			      const month = String(date.getMonth() + 1).padStart(2, '0'); // 获取月份，+1 是因为月份从 0 开始
			      const day = String(date.getDate()).padStart(2, '0'); // 获取日期
			      return `${year}-${month}-${day}`; // 返回格式化的日期字符串
			    }

		},
		onShow() {
			this.refresh()
		},
		onPullDownRefresh() {
			this.refresh()
			uni.stopPullDownRefresh()
		},
		
		onPullDownRefresh() {
			this.refresh()
			uni.stopPullDownRefresh()
		},
		onReachBottom() {
			uni.showLoading({
				title: '加载中'
			})
			if (this.hasMore) {
				this.pageNo++ 
				setTimeout(() => {
					this.getBhList()
					uni.hideLoading()
				}, 500)
			} else {
				setTimeout(() => {
					uni.hideLoading()
					uni.showToast({
						icon: 'none',
						title: '已经到低了哦',
						duration: 2000
					});
				}, 500)
			}
		},
		
		methods: {
			//补货
			// toBh(item){
			// 	console.log(item)
			// 	this.$Router.push({
			// 		name: 'replenishGoods',
			// 		params: {
			// 			id: item.id
			// 		},
			// 	});
			// },
			
			clickCard(item){
				console.log(item)
				this.$Router.replace({
					name: 'mdBhDetails',
					params: item,
				});
			},
			changeType(index) {
				this.current = index;
				console.log(this.current)
				if(this.current == 0){
					this.orderState = '待提交'
				}else if(this.current == 1){
					this.orderState = '待审核'
				}else if(this.current == 2){
					this.orderState = '待支付'
				}
				this.refresh();
			},
			getBHByGoodsNumber(value){
				 console.log(123)
				 console.log(value)
				 let dataList1 = [];
				for(let item of this.dataList) {
					if(item.goodsNumber.includes(value)){
						dataList1.push(item)
					}
				}
				this.dataList = dataList1
				if(value == null || value == '' ){
					this.refresh()
				}
			},
			checkboxChange(e){
				console.log(e)
			},
			refresh(){
				this.pageNo = 1
				this.hasMore = true
				this.dataList = [];
				uni.showLoading({
					title: '加载中...'
				})
				this.getBhList()
				uni.hideLoading()
			},
			
			
			getBhList(){
				this.$http.post('/rest/mdbh/mdbhList',{
				},{
					params: {
						trackNumber: this.keyword,
						orderState:this.orderState,
						page: this.pageNo,
						limit: 5
					},
					header: {
						'Authorization' :uni.getStorageSync('token'),
					}
				}).then(res => {
					console.log(res)
					if (this.pageNo == 1) {
						this.dataList = res.data.data
					} else {
						this.dataList = this.dataList.concat(res.data.data)
					}
					// this.orderCount = res.data.count
					this.hasMore = this.pageNo * 5 < res.data.count
					
				})
			},
		},
	}
</script>
<style lang="scss">
	.huanhang{
		word-break:break-all;
	}
</style>